[OpenVINO] Support Gemma3TextModel for feature-extraction#1799
[OpenVINO] Support Gemma3TextModel for feature-extraction#1799mlukasze wants to merge 5 commits into
Conversation
rkazants
left a comment
There was a problem hiding this comment.
needs proper PR description with code snippets
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
|
@mitruska, please check failing test https://github.com/huggingface/optimum-intel/actions/runs/28499616266/job/84473639987?pr=1799 |
|
Thanks for flagging this, @mitruska — investigated and pushed a fix in Root cause (two distinct issues, both external to this PR's diff)
Neither issue is caused by this PR's diff (only touches FixNarrowly scoped to
Verification (local)
Follow-up (logged, not addressed here to keep this PR minimal)The durable fix is re-saving CI on the new commit is currently |
Enables clean OpenVINO feature-extraction export of Gemma3 text-embedding backbones such as microsoft/harrier-oss-v1-270m. Mirrors Qwen3OpenVINOConfig feature-extraction support (huggingface#1415): excludes position_ids and exports only input_ids + attention_mask for the embedding path. - model_configs.py: inputs property override on Gemma3TextOpenVINOConfig - test_modeling.py: gemma3_text in OVModelForFeatureExtractionIntegrationTest - test_export.py: gemma3_text in ExportModelTest Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…eights tiny-random-gemma3-text on the Hub stores Gemma3ForCausalLM weights (with model. prefix) while model_type=gemma3_text. Loading via AutoModel/ Gemma3TextModel causes ALL weights to be randomly re-initialised, so the OV-exported model and the PyTorch reference end up with *different* random seeds and their outputs diverge → test_compare_to_transformers fails. Add _create_tiny_gemma3_text_model() that creates a Gemma3TextModel from the Hub config, saves its weights to a temp dir, and returns the path. MODEL_NAMES[gemma3_text] now points at this locally-saved model, so both the export and the comparison load identical weights. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Roman Kazantsev <roman.kazantsev@intel.com>
…egression) Address review feedback from rkazants on PR huggingface#1799: - Replace the atol=2e-2 workaround with forcing the reference PyTorch model to load in fp32 (torch_dtype=torch.float32), matching the precedent already used for AutoModelForCausalLM elsewhere in this test suite. gemma3_text now uses the same tight atol=1e-4 as every other architecture instead of a special-cased tolerance. - Replace the vague external-issue-reference skip reason with a concrete, verified explanation: Gemma3TextModel.base_model_prefix resolves to "language_model" on transformers==4.50.0, "" on 4.53.0/4.55.0, and only becomes "model" starting with transformers==5.0.0, which is why AutoModel.from_pretrained silently falls back to random weights on older releases instead of raising. This was empirically verified across several transformers releases.
2d0d8d4 to
65bddbb
Compare
What does this PR do?
Adds a
feature-extractioninputs override toGemma3TextOpenVINOConfigso thatGemma3TextModel-based text-embedding models (e.g.microsoft/harrier-oss-v1-270m) export cleanly to OpenVINO IR.Without the override the config inherits
GemmaOpenVINOConfig.inputs, which injectsposition_idsinto the graph and breaks sentence-transformers-style callers that pass onlyinput_ids+attention_mask.Mirrors the pattern used for
Qwen3OpenVINOConfigadded in #1415.Installation instructions
Exporting cmd-line
Inference script
Before submitting